using GraphProcessor;
using IQIGame.Onigao.Logic;

namespace IQIGame.Onigao.GamePlay.Editors
{
    [System.Serializable, NodeMenuItem(LevelEditorConst.Execution + "/" + LevelEditorConst.ChangeInteractType, typeof(LevelServiceGraph))]
    public class LevelServiceExecutionNode_ChangeInteractType : LevelServiceExecutionNode
    {
        protected override ServiceExecutionType mServiceType => ServiceExecutionType.ChangeInteractType;

        public override string name => LevelEditorConst.ChangeInteractType;
        [Output("目标", false)] public EditorLevelServiceDynamicListSetter tagOrMcid;
        [LevelServiceEditorCustomProperty(ServiceExecutionType.ChangeInteractType, "EntityInteractType表ID")] public byte interactType;

        protected override LevelServiceCustomConfig CreateConfig()
        {
            var rConfig = new LevelServiceExecutionCustom_ChangeInteractType()
            {
                // tagOrMcid = this.tagOrMcid,
                interactType = this.interactType,
                tagOrMcid = LevelServiceDynamicListSelectNode.DefaultParam
            };
            this.tagOrMcid = new EditorLevelServiceDynamicListSetter(x => rConfig.tagOrMcid = x);
            return rConfig;
        }

        protected override void OnSync(EditorLevelServiceExecutionConfig newConfig, LevelServiceExecutionNode tempNode)
        {
            if (tempNode is LevelServiceExecutionNode_ChangeInteractType rNode)
            {
                this.interactType = rNode.interactType;
            }
            if (newConfig.customConfig is LevelServiceExecutionCustom_ChangeInteractType rConfig)
            {
                this.SyncTarget(rConfig.tagOrMcid);
            }
        }
    }
}